TAR_CLI = client 
TAR_SER = server
TAR_MDEMO = mdemo

CLI_SRCS = RetroreflectionClient.c SocketTimeOut.c NetWorkProDefine.c
SER_SRCS = RetroreflectionServer.c SocketTimeOut.c NetWorkProDefine.c

CLI_OBJS = $(CLI_SRCS:.c=.o) 
SER_OBJS = $(SER_SRCS:.c=.o)
MDEMO_OBJS = MulticastDemo.o ErrMsgPro.o SocketTimeOut.o NetWorkProDefine.o

MDEMO_INC += -I./Multicast -I./
CFLAGS += -g

LDFLAGS += -lpthread

$(TAR_CLI): $(CLI_OBJS)
	$(CC) $^ $(LDFLAGS) -o $@

$(TAR_SER): $(SER_OBJS)
	$(CC) $^ $(LDFLAGS) -o $@	


$(TAR_MDEMO): $(MDEMO_OBJS)
	$(CC) $^ $(LDFLAGS) -o $@ -lMulticast -L./Multicast

%.o: %.c
	$(CC) $(CFLAGS) $(MDEMO_INC) -c $^

default:$(TAR_CLI) $(TAR_SER)

.PHONY:clean clean_cli clean_ser

clean_cli:
	-rm -f $(TAR_CLI)

clean_ser:
	-rm -f $(TAR_SER)


clean:
	-rm -f ./*.o
	-rm -f $(TAR_CLI)
	-rm -f $(TAR_SER)
	-rm -f $(TAR_MDEMO)